home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / SCSI Samples 1.0 / SCSI Find Devices 06⁄15 ƒ / Src / SCSIFindDevices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-16  |  4.6 KB  |  106 lines  |  [TEXT/KAHL]

  1. /*                                SCSIFindDevices.h                                */
  2. /*
  3.  * SCSIFindDevices.h
  4.  * Copyright © 1992-94 Apple Computer Inc. All Rights Reserved.
  5.  */
  6. /*
  7.  * Include the O.S. files in a specific order to make sure that we have
  8.  * a definition for the _SCSIAtomic trap.
  9.  */
  10. #include <Traps.h>
  11. #ifndef _SCSIAtomic
  12. #define _SCSIAtomic    0xA089
  13. #endif
  14. /*
  15.  * This uses the new "common" SCSI.h which is not yet in the public
  16.  * header folders.
  17.  */
  18. #include "SCSI.h"
  19.  
  20. /*
  21.  * This is a parameter block for SCSIFindNextDevice that contains the data shared
  22.  * with the calling program and the internal state that the function needs to
  23.  * sequence between each device. If SCSIFindNextDevice succeeds, the device
  24.  * inquiry data is stored in the record.
  25.  */
  26. struct SCSIFindDevicesRec {
  27. /* Public variables */
  28.     DeviceIdent            deviceID;                /* <-> Bus/target/LUN            */
  29.     short                maxLUN;                    /* ->  Maximum logical units    */
  30.     Boolean                isAsyncSCSIPresent;        /* <-  TRUE if SCSI Manager 4.3    */
  31.     long                refNum;                    /*       Reserved for the caller    */
  32.     long                actualInquirySize;        /* <- data length in inquiry    */
  33.     struct SCSI_Inquiry_Data {                    /* <- Inquiry returns this        */
  34.         unsigned char        devType;            /*  0 Device type,                */
  35.         unsigned char        devTypeMod;            /*  1 Device type modifier        */
  36.         unsigned char        version;            /*  2 ISO/ECMA/ANSI version        */
  37.         unsigned char        format;                /*  3 Response data format        */
  38.         unsigned char        length;                /*  4 Additional Length            */
  39.         unsigned char        reserved5;            /*  5 Reserved                    */
  40.         unsigned char        reserved6;            /*  6 Reserved                    */
  41.         unsigned char        flags;                /*  7 Capability flags            */
  42.         unsigned char        vendor[8];            /*  8-15 Vendor-specific        */
  43.         unsigned char        product[16];        /* 16-31 Product id                */
  44.         unsigned char        revision[4];        /* 32-35 Product revision        */
  45.         unsigned char        vendorSpecific[20]; /* 36-55 Vendor stuff            */
  46.         unsigned char        moreReserved[40];    /* 56-95 Reserved                */
  47.     } inquiry;
  48. /* Private variables */
  49.         short                state;                /* Control overall operation    */
  50.         unsigned short        lastHostBus;        /* Host bus iteration limit        */
  51.         Boolean                useAsynchSCSI;        /* Is asynch ok on this bus?    */
  52.         unsigned short        initiatorID;        /* Host processor bus ID        */
  53.         unsigned short        maxTargetID;        /* Max target on this bus        */
  54.         short                maxBusLUN;            /* Max LUN on this bus            */
  55.         Boolean                enableATN;            /* Select with ATN on this bus?    */
  56.         unsigned long        execIOPBSize;        /* SCSIAction pb size            */
  57.         SCSIExecIOPB        *scsiExecIOPB;        /* Set on bus-by-bus basis        */
  58. };
  59. typedef struct SCSIFindDevicesRec SCSIFindDevicesRec, *SCSIFindDevicesPtr;
  60. /*
  61.  * Notes on the above:
  62.  * Public variables:
  63.  *    deviceID            This is the current SCSI device. If deviceID.bus == 0xFF
  64.  *                        SCSIFindNextDevice will initialize itself.
  65.  *    maxLUN                Set to zero to ignore logical units or seven to test
  66.  *                        all targets for multiple logical units. Beware: some
  67.  *                        devices fail miserably if a non-zero logical unit is
  68.  *                        selected.
  69.  *    isAsyncSCSIPresent    Set TRUE after the first call to SCSIFindNextDevice if
  70.  *                        the asynchronous SCSI Manager (SCSI Manager 4.3) is
  71.  *                        running.
  72.  *    actualInquirySize    If the function succeeds, it returns the Device Inquiry
  73.  *                        information in the inquiry field. actualInquirySize
  74.  *                        is the length of the data that was returned.
  75.  *    inquiry                This is the device information returned on success.
  76.  * Private variables:
  77.  *    state                This manages the overall code flow in the subroutine.
  78.  *    lastHostBus            The highest host bus on this system (if asynch present)
  79.  *    useAsynchSCSI        TRUE if the asynchronous SCSI Manager works on this bus
  80.  *    initiatorID            The bus ID of the Macintosh. Normally 7
  81.  *    maxTargetID            The maximum target bus ID on this host bus.
  82.  *    enableATN            Enable "select with attention" if set. This works around
  83.  *                        a bug on un-patched Quadra 660-av and 840-av systems.
  84.  *    execIOPBSize        The size of the SCSI parameter block.
  85.  *    scsiExecIOPB        A pointer to the SCSI parameter block.
  86.  */
  87.     
  88. /*
  89.  * SCSIFindNextDevice:
  90.  *    Scan the SCSI bus(es) for the next device. This will scan all buses, all
  91.  *    targets, and all logical units in order. To initialize, set deviceID.bus to
  92.  *    0xFF and maxLUN to zero or seven as needed.
  93.  *    SCSIFindNextDevice allocates memory.
  94.  *
  95.  *    Return:
  96.  *        noErr            The deviceID field contains the next SCSI device and
  97.  *                        the inquiry structure contains device-specific information.
  98.  *        eofErr            The last device has been found. This is a normal status.
  99.  *        other errors    Something horrible happened, such as a memory error.
  100.  *                        (If your application calls SCSIFindNextDevice after any
  101.  *                        error status, it will start from the beginning.)
  102.  */
  103. OSErr                        SCSIFindNextDevice(
  104.         SCSIFindDevicesPtr        scsiFindDevicesPtr
  105.     );
  106.